**************************************************************************************
************************************************************************************** 
****                                                                              ****
**** The following STATA program files were used for the analysis in:             ****
****                                                                              ****
**** Chen S, Christensen T, Ma L. Competing for father's love? The politics       ****
**** of central government agency termination in China.                           ****
**** Governance. 2019,32:761–777.                                                ****
****                                                                              ****
**** Please kindly acknowledge us when publishing your work using this data       ****
**** source--be it in whole or in part.                                           ****
****                                                                              ****
**** Contact us if you have any questions concerning either the data              ****
**** structure or programming.                                                    ****
****                                                                              ****
**************************************************************************************
**************************************************************************************

use chinadura.dta,clear

****Table 2. The random-effects logit model estimates
quietly xtlogit death log_ypishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store g1
quietly xtlogit death c.log_ypishi##i.economy reformteammember turnover log_staff age age2 create levelnew surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store g2
quietly xtlogit death c.log_ypishi##i.levelnew reformteammember turnover log_staff age age2 create economy surplus nps1954 nps1959 nps1965 nps1975, re or iterate(150)
quietly est store g3
quietly xtlogit death c.log_ypishi##c.log_staff reformteammember turnover age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store g4

esttab g* using result_g1.rtf, se eform par ///
stats(N ll r2_p, fmt(0 2 2) label(N "log likelihood" "Pseudo R2")) ///
starlevels(* 0.10 ** 0.05 *** 0.01) replace


****Figure 1. The marginal effects of annual written directives (log) on the probability of agency termination by agency level
quietly xtlogit death c.log_ypishi##i.economy reformteammember turnover log_staff age age2 create levelnew surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
marginscontplot2 log_ypishi economy, at2(0 1) lineopts(lcolor(red black) lpattern(l --) lwidth(medthick medthick))


****Figure 2. The marginal effects of annual written directives (log) on the probability of agency termination by agency level
quietly xtlogit death c.log_ypishi##i.levelnew reformteammember turnover log_staff age age2 create economy surplus nps1954 nps1959 nps1965 nps1975, re or iterate(150)
marginscontplot2 log_ypishi levelnew, at2(0 1) lineopts(lcolor(red black) lpattern(l --) lwidth(medthick medthick))


****Figure 3. The marginal effects of annual written directives (log) on the probability of agency termination by agency size
quietly xtlogit death c.log_ypishi##c.log_staff reformteammember turnover age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
marginscontplot2 log_ypishi log_staff, at2(4.8 7.1) lineopts(lcolor(red black) lpattern(l --) lwidth(medthick medthick))



****Table A2. The random-effects logit model estimates (with alternative measurements)

**lagged annual pishi
quietly xtlogit death lag_ypishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r1

***moving average by 3 years

quietly xtlogit death ma3_pishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r2

***moving average by 5 years

quietly xtlogit death ma5_pishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r3

**lagged yearly-averaged pishi

quietly xtlogit death lag_pishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r4

***lagged commulative pishi

quietly xtlogit death lag_cumpishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r5

***dummy of pishi

quietly xtlogit death ypishi_dummy reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r6

**Mao's negative pishi
quietly xtlogit death log_mpish_pos reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r7
quietly xtlogit death log_mpish_pos log_maonegiveps reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r8


esttab r* using result_r3.rtf, se eform par ///
stats(N ll r2_p, fmt(0 2 2) label(N "log likelihood" "Pseudo R2")) ///
starlevels(* 0.10 ** 0.05 *** 0.01) replace



****Table A3. The random-effects logit model estimates (with alternative measurements and model specifications)


**Zhou pishi and Liu pishi

quietly xtlogit death log_mzlpishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r9
quietly xtlogit death log_ypishi log_zlpishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r10
quietly xtlogit death log_ypishi log_zhoupishi log_liups reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975, re or vce(cluster agencyid)
quietly est store r11

**The Cultural Revolution
quietly xtlogit death log_ypishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975 if wenge==0, re or vce(cluster agencyid)
quietly est store r12
quietly xtlogit death log_ypishi reformteammember turnover log_staff age age2 create levelnew economy surplus nps1954 nps1959 nps1965 nps1975 if wenge==1, re or vce(cluster agencyid)
quietly est store r13


esttab r* using result_r3.rtf, se eform par ///
stats(N ll r2_p, fmt(0 2 2) label(N "log likelihood" "Pseudo R2")) ///
starlevels(* 0.10 ** 0.05 *** 0.01) replace

